import { Button, Input } from 'antd'
import { ConfigProvider } from 'antd'

import SelNursingWorkerModal from '../SelNursingWorkerModal'

const NursingWorkerSelect = ({
  value,
  onChange,
  disabled,
  companionType,
  companionCompanyId,
  patientName,
  phoneNo,
  orderNo,
}) => {
  const selNursingWorker = async () => {
    const { nursingWorke } = await SelNursingWorkerModal.PromiseThen({
      companionType,
      companionCompanyId,
      patientName,
      phoneNo,
      orderNo,
    })
    onChange(nursingWorke)
  }

  return (
    <div className='flex'>
      <Input readOnly value={value?.name} placeholder='请选择' />
      <ConfigProvider
        theme={{
          components: {
            Button: {
              paddingBlock: 0,
              paddingInline: 0,
            },
          },
        }}
      >
        <Button className='ml10px' type='link' onClick={selNursingWorker} disabled={disabled}>
          选择
        </Button>
      </ConfigProvider>
    </div>
  )
}

export default NursingWorkerSelect
